Skip to main content
Version: 6.0.0-beta.3 - 6.0.0-beta.4

toHex

Convert any value to HEX.

❗️Note:

This function does not convert TRON address to Hex. If you wish to specifically convert TRX addresses to HEX, please use TronWeb.address.toHex instead.

Usage

TronWeb.toHex(value);

Parameters

ParameterDescriptionData Type
valueThe value to be converted to HEX.String, Number, Object, Array or BigNumber

Returns

String

Example


> TronWeb.toHex("abcABC")
> "0x616263414243"
// If it is an object or array type, it will first be converted to a string using JSON.stringify.
> TronWeb.toHex({ abc: "ABC" })
> "0x7b22616263223a22414243227d"